package com.cbw.service;

import com.cbw.bean.BootStrapTableExpress;
import com.cbw.bean.BootStrapTableUser;
import com.cbw.bean.Express;
import com.cbw.bean.User;
import com.cbw.dao.BaseUserDao;
import com.cbw.dao.ImpI.BaseUserDaoMysql;
import com.cbw.util.DateFormatUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class UserService {
    private static BaseUserDao dao=new BaseUserDaoMysql();

    public static List<Map<String,Integer>>console(){
        return dao.console();
    }

    /**
     * 查询所有用户(区分分页与否)
     * @param limit  是否分页 true为分页
     * @param offset 查询数据的开始索引
     * @param pageNum 每页记录数
     * @return
     */
    public static List<User> findALl(boolean limit, int offset, int pageNum){
        /*List<User> list = dao.findALl(limit, offset, pageNum);
        ArrayList<BootStrapTableUser> list1 = new ArrayList<>();
        for ( User user : list) {
            String createtime = DateFormatUtil.format(user.getCreateTime());//将TimeStamp类型转成string
            String lastTime =DateFormatUtil.format(user.getLastTime());
            new BootStrapTableUser()
            list1.add(e2);
        }*/
        return dao.findALl(limit,offset,pageNum);}

    /**
     * 通过手机查询用户
     * @param userPhone
     * @return
     */
    public static User findUserByUserPhone(String userPhone){return dao.findUserByUserPhone(userPhone);};

    /**
     * 增加用户
     * @param user
     * @return
     */
    public static boolean insert(User user){

        return dao.insert(user);};

    /**
     * 修改用户
     * @param user
     * @return
     */
    public static boolean update(User user){return dao.update(user);};

    /**
     * 删除用户
     * @param id
     * @return
     */
    public static boolean delete(int id){return dao.delete(id);};

    public static int total() {
        return dao.total();
    }

}
